/*     */ package com.md5viewer;
/*     */

import com.jme.app.AbstractGame;
/*     */ import com.jme.app.SimpleGame;
/*     */ import com.jme.input.KeyBindingManager;
import com.jme.math.Vector3f;
/*     */ import com.jme.util.resource.MultiFormatResourceLocator;
/*     */ import com.jme.util.resource.ResourceLocatorTool;
/*     */ import com.md5viewer.enumn.EFileType;
/*     */ import com.model.md5.ModelNode;
/*     */ import com.model.md5.importer.MD5Importer;
/*     */ import java.awt.Font;
/*     */ import java.io.File;
/*     */ import java.io.IOException;
/*     */ import java.net.MalformedURLException;
/*     */ import java.net.URISyntaxException;
/*     */ import java.net.URL;
/*     */ import javax.swing.JFileChooser;
/*     */ import javax.swing.UIManager;
/*     */ import javax.swing.UnsupportedLookAndFeelException;
/*     */ import javax.swing.filechooser.FileNameExtensionFilter;
import modelos.ModelConverter;
/*     */
/*     */ public class MD5Viewer extends SimpleGame /*     */ {
  /*     */ private final JFileChooser chooser;
  /*     */ private URL mesh;
  /*     */ private URL anim;
  /*     */ private float speed;
  /*     */ private float scale;
  /*     */
  /*     */ public static void main(String[] args) /*     */ {
    /*  59 */ MD5Viewer app = new MD5Viewer();
    /*  60 */ app.mesh = app.selectFile(EFileType.Mesh);
    /*  61 */ if (app.mesh == null) {
      System.exit(-1);
    }
    /*  62 */ app.anim = app.selectFile(EFileType.Animation);
    /*  63 */ app.start();
    /*     */  }
  /*     */
  /*     */ public MD5Viewer() /*     */ {
    /*  70 */ initTheme();
    /*  71 */ setConfigShowMode(AbstractGame.ConfigShowMode.AlwaysShow);
    /*  72 */ this.chooser = new JFileChooser();
    /*  73 */ this.speed = 1.0F;
    /*  74 */ this.scale = 1.0F;
    /*     */  }
  /*     */
  /*     */ private void initTheme() /*     */ {
    /*     */ try /*     */ {
      /*  82 */ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
      /*     */    } catch (ClassNotFoundException e) {
      /*  84 */ e.printStackTrace();
      /*     */    } catch (InstantiationException e) {
      /*  86 */ e.printStackTrace();
      /*     */    } catch (IllegalAccessException e) {
      /*  88 */ e.printStackTrace();
      /*     */    } catch (UnsupportedLookAndFeelException e) {
      /*  90 */ e.printStackTrace();
      /*     */    }
    /*  92 */ UIManager.put("Button.font", new Font("Tohama", 0, 11));
    /*  93 */ UIManager.put("ToggleButton.font", new Font("Tohama", 0, 11));
    /*  94 */ UIManager.put("RadioButton.font", new Font("Tohama", 0, 11));
    /*  95 */ UIManager.put("CheckBox.font", new Font("Tohama", 0, 11));
    /*  96 */ UIManager.put("ColorChooser.font", new Font("Tohama", 0, 11));
    /*  97 */ UIManager.put("ComboBox.font", new Font("Tohama", 0, 11));
    /*  98 */ UIManager.put("Label.font", new Font("Tohama", 0, 11));
    /*  99 */ UIManager.put("List.font", new Font("Tohama", 0, 11));
    /* 100 */ UIManager.put("MenuBar.font", new Font("Tohama", 0, 11));
    /* 101 */ UIManager.put("MenuItem.font", new Font("Tohama", 0, 11));
    /* 102 */ UIManager.put("RadioButtonMenuItem.font", new Font("Tohama", 0, 11));
    /* 103 */ UIManager.put("CheckBoxMenuItem.font", new Font("Tohama", 0, 11));
    /* 104 */ UIManager.put("Menu.font", new Font("Tohama", 0, 11));
    /* 105 */ UIManager.put("PopupMenu.font", new Font("Tohama", 0, 11));
    /* 106 */ UIManager.put("OptionPane.font", new Font("Tohama", 0, 11));
    /* 107 */ UIManager.put("Panel.font", new Font("Tohama", 0, 11));
    /* 108 */ UIManager.put("ProgressBar.font", new Font("Tohama", 0, 11));
    /* 109 */ UIManager.put("ScrollPane.font", new Font("Tohama", 0, 11));
    /* 110 */ UIManager.put("Viewport.font", new Font("Tohama", 0, 11));
    /* 111 */ UIManager.put("TabbedPane.font", new Font("Tohama", 0, 11));
    /* 112 */ UIManager.put("Table.font", new Font("Tohama", 0, 11));
    /* 113 */ UIManager.put("TableHeader.font", new Font("Tohama", 0, 11));
    /* 114 */ UIManager.put("TextField.font", new Font("Tohama", 0, 11));
    /* 115 */ UIManager.put("PasswordField.font", new Font("Tohama", 0, 11));
    /* 116 */ UIManager.put("TextArea.font", new Font("Tohama", 0, 11));
    /* 117 */ UIManager.put("TextPane.font", new Font("Tohama", 0, 11));
    /* 118 */ UIManager.put("EditorPane.font", new Font("Tohama", 0, 11));
    /* 119 */ UIManager.put("TitledBorder.font", new Font("Tohama", 0, 11));
    /* 120 */ UIManager.put("ToolBar.font", new Font("Tohama", 0, 11));
    /* 121 */ UIManager.put("ToolTip.font", new Font("Tohama", 0, 11));
    /* 122 */ UIManager.put("Tree.font", new Font("Tohama", 0, 11));
    /*     */  }
  /*     */
  /*     */ private URL selectFile(EFileType type) /*     */ {
    /* 131 */ String promt = "";

    /* 132 */ FileNameExtensionFilter filter = null;

    /* 133 */ switch (type.ordinal()) /*     */ {
      /*     */ case 0:
        /* 135 */ promt = "Select MD5Mesh file";
        /* 136 */ filter = new FileNameExtensionFilter("Mesh", new String[]{"md5mesh"});
        /* 137 */ break;
      /*     */ case 1:
        /* 139 */ promt = "Select MD5Anim file";
        /* 140 */ filter = new FileNameExtensionFilter("Animation", new String[]{"md5anim"});
      /*     */    }
    /*     */
    /* 143 */ this.chooser.setDialogTitle(promt);
    /* 144 */ this.chooser.setFileFilter(filter);
    /* 145 */ if (this.chooser.showOpenDialog(null) == 0) {
      /* 146 */ File file = this.chooser.getSelectedFile();
      /*     */ try {
        /* 148 */ return file.toURI().toURL();
        /*     */      } catch (MalformedURLException e) {
        /* 150 */ e.printStackTrace();
        /*     */      }
      /*     */    }
    /* 153 */ return null;
    /*     */  }
  /*     */
  /*     */ protected void simpleInitGame() /*     */ {
    /* 158 */ setupKeyBindings();
    /* 159 */ overrideTextureKey();
    /*     */
    /* 161 */ if ((this.mesh != null) && (this.anim == null)) {
      /*     */ try {
        /* 163 */ MD5Importer.getInstance().loadMesh(this.mesh, "Mesh");
        /*     */      } catch (IOException e) {
        /* 165 */ e.printStackTrace();
        /*     */      }
      /*     */    } /* 168 */ else if ((this.mesh != null) && (this.anim != null)) {
      /*     */ try {
        /* 170 */ MD5Importer.getInstance().load(this.mesh, "Mesh", this.anim, "Animation", 1);
        /*     */      } catch (IOException e) {
        /* 172 */ e.printStackTrace();
        /*     */      }
      /*     */    }
    /* 175 */ ModelNode model = MD5Importer.getInstance().getModelNode();
    model.getLocalRotation().fromAngleAxis((float) Math.toRadians(90), Vector3f.UNIT_Z);

    /* 176 */ this.rootNode.attachChild(model);
    /* 177 */ MD5Importer.getInstance().cleanup();
    /*     */  }
  /*     */
  /*     */ private void setupKeyBindings() /*     */ {
    /* 184 */ KeyBindingManager.getKeyBindingManager().set("speedup", 2);
    /* 185 */ KeyBindingManager.getKeyBindingManager().set("slowdown", 3);
    /* 186 */ KeyBindingManager.getKeyBindingManager().set("scaleup", 4);
    /* 187 */ KeyBindingManager.getKeyBindingManager().set("scaledown", 5);
    /*     */  }
  /*     */
  /*     */ private void overrideTextureKey() /*     */ {
    /*     */ try /*     */ {
      String a = this.mesh.getPath();

      URL directorio = ModelConverter.class.getClassLoader().getResource("modelos/");

      /* 195 */ MultiFormatResourceLocator locator = new MultiFormatResourceLocator(directorio, new String[]{".tga", ".bmp", ".jpg", ".png", ".JPG"});
      /* 196 */ ResourceLocatorTool.addResourceLocator("texture", locator);
    } catch (URISyntaxException e) {
      /* 197 */ e.printStackTrace();
    }
    /*     */  }
  /*     */
  /*     */ protected void simpleUpdate() {
    /* 201 */ if (KeyBindingManager.getKeyBindingManager().isValidCommand("speedup", false)) {
      /* 202 */ this.speed += 1.0F;
      /* 203 */ this.input.setActionSpeed(this.speed);
      /* 204 */    } else if (KeyBindingManager.getKeyBindingManager().isValidCommand("slowdown", false)) {
      /* 205 */ this.speed -= 1.0F;
      /* 206 */ this.input.setActionSpeed(this.speed);
      /* 207 */    } else if (KeyBindingManager.getKeyBindingManager().isValidCommand("scaleup", false)) {
      /* 208 */ this.scale += 0.2F;
      /* 209 */ this.rootNode.setLocalScale(this.scale);
      /* 210 */    } else if (KeyBindingManager.getKeyBindingManager().isValidCommand("scaledown", false)) {
      /* 211 */ this.scale -= 0.2F;
      /* 212 */ this.rootNode.setLocalScale(this.scale);
      /*     */    }
    /*     */  }
  /*     */ }

/* Location:           C:\Users\yamit_alejandro\Desktop\MD5Viewer_v1.2.0\MD5Viewer_v1.2.0\MD5Viewer_v1.2.0\
 * Qualified Name:     com.md5viewer.MD5Viewer
 * JD-Core Version:    0.5.3
 */
